from django.db import models


# Create your models here.
class VipCard(models.Model):
    cardname = models.CharField(max_length=100, verbose_name="卡种类")
    num = models.IntegerField(verbose_name="天数")
    content = models.CharField(max_length=150, verbose_name="描述")
    price = models.DecimalField(max_digits=8, decimal_places=2, verbose_name="价格")
    img = models.ImageField(upload_to="avatar", max_length=255, verbose_name="封面", blank=True, null=True)

    class Meta:
        db_table = "swim_vipcard"
        verbose_name = "vip卡种类"
        verbose_name_plural = "vip卡种类"

    def __str__(self):
        return "%s" % self.cardname


class VipUser(models.Model):
    username = models.CharField(max_length=100, verbose_name="用户名")
    cardname = models.CharField(max_length=100, verbose_name="卡类型")
    cardno = models.CharField(max_length=100, verbose_name="卡号", unique=True)
    create_time = models.DateField(verbose_name="发卡日期", auto_now_add=True)
    daynum = models.IntegerField(verbose_name="剩余天数")
    is_open = models.BooleanField(default=True, verbose_name='是否失效')

    class Meta:
        db_table = "swim_vipuser"
        verbose_name = "会员表"
        verbose_name_plural = verbose_name

    def __str__(self):
        return "%s" % self.username
